package com.ksd.modules.members.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ksd.commons.BaseServiceImpl;
import com.ksd.modules.members.entity.AdminUserRegisterConfig;
import com.ksd.modules.members.mapper.AdminUserRegisterConfigMapper;
import com.ksd.modules.members.po.AdminUserRegisterConfigSavePO;
import com.ksd.modules.members.po.AdminUserRegisterConfigSearchPO;
import com.ksd.modules.members.service.IAdminUserRegisterConfigService;
import com.ksd.modules.members.vo.AdminUserRegisterConfigVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class AdminUserRegisterConfigServiceImpl extends BaseServiceImpl<AdminUserRegisterConfigMapper, AdminUserRegisterConfig> implements IAdminUserRegisterConfigService {


    /**
     * 查询列表
     * @param adminUserBenefitsSearchPO
     * @return
     */
    public Page<AdminUserRegisterConfigVo> findAdminUserRegisterConfig(AdminUserRegisterConfigSearchPO adminUserBenefitsSearchPO){
        Page<AdminUserRegisterConfig> page = new Page<>(adminUserBenefitsSearchPO.getPageNo(),adminUserBenefitsSearchPO.getPageSize());
        LambdaQueryWrapper<AdminUserRegisterConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        Page<AdminUserRegisterConfig> adminUserBenefitsPage = this.page(page, lambdaQueryWrapper);
        Page<AdminUserRegisterConfigVo> adminUserBenefitsVoPage = tranferPageBo(adminUserBenefitsPage, AdminUserRegisterConfigVo.class);
        return adminUserBenefitsVoPage;
    }


    /**
     * 保存和更新
     * @param adminUserBenefitsSavePO
     * @return
     */
    @Transactional(rollbackFor=Exception.class)
    public AdminUserRegisterConfigVo saveUpdateAdminUserRegisterConfig(AdminUserRegisterConfigSavePO adminUserBenefitsSavePO){
        AdminUserRegisterConfig adminUserBenefits = tranferBo(adminUserBenefitsSavePO, AdminUserRegisterConfig.class);
        boolean b = this.saveOrUpdate(adminUserBenefits);
        AdminUserRegisterConfigVo adminUserBenefitsVo = tranferBo(adminUserBenefits, AdminUserRegisterConfigVo.class);
        return adminUserBenefitsVo;
    }

    /**
     * 根据ID获取明细
     * @param id
     * @return
     */
    public AdminUserRegisterConfigVo getAdminUserRegisterConfigById(Long id){
        AdminUserRegisterConfig adminUserBenefits = this.getById(id);
        AdminUserRegisterConfigVo adminUserBenefitsVo = tranferBo(adminUserBenefits, AdminUserRegisterConfigVo.class);
        return adminUserBenefitsVo;
    }
}
